The encodeURIComponent () function encodes a string as a URI component.
Syntax: encodeURIComponent (uristring)
Parameter description: uristring required. A string that contains the URI component or other text to encode.
Return value: A copy of
Escape (), encodeuri () and encodeuricomponent () are three common methods used to encode strings in Javascript, but their similarities and differences have plagued many JavaScript beginners, today, I will analyze and compare these three methods in
Escape () method
The MSDN JScript reference says:
The Escape method returns a string value, in Unicode format, that contains the contents of [the argument]. All spaces, punctuation, accented characters, and no other non-ascii characters-are with
Comparison | function |escape|encodeuri|encodeuricomponent
JS encoding text involves 3 functions: Escape,encodeuri,encodeuricomponent, corresponding 3 decoding functions: Unescape,decodeuri,decodeuricomponent
1, the transfer of parameters need to
Escape () method
In the MSDN JScript Reference:
The escape method returns a string value (in Unicode format) that contains the contents of [the argument]. all spaces, punctuation, accented characters, and any other non-ASCII characters are replaced
Escape (), encodeURI () and encodeURIComponent () are three common methods used to encode strings in Javascript, but their similarities and differences have plagued many Javascript beginners, today, I will analyze and compare these three methods in
encodeURI (), encodeURIComponent (), decodeURI (), decodeuricomponent () URL encodingThe encodeURI () and encodeURIComponent () methods of the global object encode the URI for sending to the browser. A valid URI cannot contain certain characters,
JavaScript code involves three functions: Escape, encodeuri, and encodeuricomponent. The corresponding three decoding functions are: Unescape, decodeuri, and decodeuricomponent.
1. encodeuricomponent is required when passing parameters so that the
There are three functions in JavaScript that can encode strings, namely: Escape,encodeuri,encodeuricomponent, corresponding 3 decoding functions:, decodeuri,decodeuricomponent.Here's a brief look at the difference between them1 Escape ()
There are three functions in JavaScript that can encode strings, namely: Escape,encodeuri,encodeuricomponent, corresponding 3 decoding functions: Unescape,decodeuri, decodeURIComponent.Here's a brief look at the difference between them1 Escape ()
For ASCII characters, these three functions are used to convert characters into Percent-encoding (Percent-encoding). The difference is that the characters are different in their respective exclusion codes:
Escape () will not encode: @ */+
EncodeURI (
Escape (), encodeuri () and encodeuricomponent () are three common methods used to encode strings in Javascript, but their similarities and differences have plagued many JavaScript beginners, today, I will analyze and compare these three methods
Escape, encodeURI, encodeURIComponent 1) Basic Introduction JS to encode the text involves 3 functions: escape,encodeuri,encodeuricomponent, Corresponding 3 decoding functions:decodeuri,decodeuricomponent 2) Use 1, passing parameters need to use
Before we introduce the encodeURI (), encodeURIComponent (), decodeURI (), decodeURIComponent () methods, we need to understand the concept of the global object:The global (Global) object can be said to be the most special object in ECMAScript,
JS to encode the text involves 3 functions: Escape,encodeuri,encodeuricomponent, the corresponding 3 decoding function: unescape,decodeuri,decodeuricomponent 1, passing parameters need to use encodeuricomponent, so that the combined URL will not be #
Turn from: http://blog.csdn.net/ljb2010_/archive/2010/12/13/6073507.aspx
Coding is often used in AJAX development, especially in Chinese. So what did Encodeuri,encodecomponent do? Why are there encodeURI, and encodeuricomponent?
Knowledge URI
It is estimated that many front-end engineers do not know the difference between Escape,encodeuri, encodeURIComponent, or when to use which method, and why these methods should be used, and I will mainly explain the differences and usage of these
encodeURIComponent () Definition and usageThe encodeURIComponent () function encodes a string as a URI component.syntax :encodeuricomponent (uristring)parameter Description : uristring required. A string that contains the URI component or other text
Usually if something needs to be coded, it means that something is not suitable for transmission. There are a variety of reasons, such as size too large to contain private data, and for URLs, the reason for encoding is because some characters in the
1. Eacape (): This method does not encode ASCII letters and numbers, nor does it encode the following ASCII punctuation marks: * @-_ +. / 。 All other characters will be replaced by escape sequences. In other cases the
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.